/*
 * @Author: yxiawen
 * @Date: 2021-11-24 10:29:03
 * @LastEditTime: 2022-01-24 15:55:24
 * @LastEditors: yxiawen
 * @Description:store
 * @FilePath: /vite-project/src/store/index.js
 */
// import Vue from "vue";
// import Vuex from "vuex";

// Vue.use(Vuex);

// const store = new Vuex.Store(modules);
// export default store;
import { createStore } from "vuex";
import createPersistedState from "vuex-persistedstate";
const files = require.context("./modules", false, /\.js$/);
const modules = {
  state: {},
  mutations: {},
  actions: {},
  getters: {}
};

files.keys().forEach(key => {
  Object.assign(modules.state, files(key).state);
  Object.assign(modules.mutations, files(key).mutations);
  Object.assign(modules.actions, files(key).actions);
  Object.assign(modules.getters, files(key).getters);
});
console.log(modules);
const store = createStore({
  modules: { modules },
  plugins: [createPersistedState()]
});

export default store;
